import { defineConfig, loadEnv } from "vite";
import { fileURLToPath, URL } from "node:url";
import path from "path";
import react from "@vitejs/plugin-react";
import cesium from 'vite-plugin-cesium'
// https://vite.dev/config/
export default defineConfig((config) => {
  console.log("当前环境配置：", config);
  const envDir = path.resolve(__dirname, "env");
  // 加载环境变量(参数为：当前环境、环境变量目录、环境变量前缀数组)
  const env = loadEnv(config.mode, envDir,["VITE_", "API_"]); 
  console.log("当前环境变量：", env);
  return {
    base: "/react-single",
    envDir: path.resolve(__dirname , "env"),
    server: {
      port: 2565,
    },
    plugins: [react(),cesium()],
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
    },
  };
});
